﻿
@{
    ViewBag.Title = "Json生成类";
}

<h2>根据Json生成类</h2>

@using (Html.BeginForm("JsonToClass", "JsonConvert", FormMethod.Get, new { id = "compareForm", @class = "form-horizontal" }))
{
    <div class="form-group">
        <label>Json字符串：</label>
        <div>
            <textarea class="form-control" id="strJson" placeholder="Json字符串" rows="10"></textarea>
        </div>
    </div>
    <div class="form-group">
        <button type="button" id="" onclick="ToClass()" class="btn btn-primary" style="width:100%;">转换</button>
    </div>
}

<div class="panel panel-default">
    <div class="panel-body">
        请输入Json内容后点击生成转换按钮
    </div>
</div>

<script>
    function ToClass() {
        var strJson = $("#strJson").val();
        if (strJson) {
            $.post("JsonToClass", { str: strJson }, function (res) {
                if (res.Status) {
                    $(".panel-body").html(res.Data.replace(/\r\n/g,"<Br />"));
                }
                else {
                    $(".panel-body").html(res.Msg);
                }
            });
        }
    }
</script>